using System;
using System.Collections;
using System.Collections.Specialized;
using System.Data;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using System.Text;
using ECommerce.DAL;
using eShop.Model;
using System.Collections.Generic;


namespace eShop.DataAccess
{

    [System.ComponentModel.DataObject]
    public class ManufacturerDAO : DatabaseUtility
    {
        public static CustomCollection<Manufacturer> GetProductBrandsByPrefix(string prefix)
        {
            if (string.IsNullOrEmpty(prefix))
                throw (new ArgumentOutOfRangeException("prefix"));

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@Prefix", SqlDbType.NVarChar, 50, ParameterDirection.Input, prefix);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_PRODUCTBRAND_GET_TBL_PRODUCT_BRAND_BY_PREFIX);
            GenerateCollectionFromReader reader = new GenerateCollectionFromReader(GenerateTblProductBrandCollectionFromReader);
            CustomCollection<Manufacturer> objCollection = ((CustomCollection<Manufacturer>)ExecuteReaderCmd(sqlCmd, reader));

            return objCollection;
        }

        public static CustomCollection<Manufacturer> GetProductBrandsByCondition(int howMany, bool active, bool featured, bool deleted)
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@HowMany", SqlDbType.Int, 0, ParameterDirection.Input, howMany);
            AddParameterToSqlCmd(sqlCmd, "@Active", SqlDbType.Bit, 0, ParameterDirection.Input, active);
            AddParameterToSqlCmd(sqlCmd, "@Featured", SqlDbType.Bit, 0, ParameterDirection.Input, featured);
            AddParameterToSqlCmd(sqlCmd, "@Deleted", SqlDbType.Bit, 0, ParameterDirection.Input, deleted);

            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_PRODUCTBRAND_GET_TBL_PRODUCT_BRAND_BY_CONDITION);
            GenerateCollectionFromReader reader = new GenerateCollectionFromReader(GenerateTblProductBrandCollectionFromReader);
            CustomCollection<Manufacturer> objCollection = ((CustomCollection<Manufacturer>)ExecuteReaderCmd(sqlCmd, reader));

            return objCollection;
        }
        public static CustomCollection<Manufacturer> GetProductBrandsByPertnerCategory(int categoryId)
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@CategoryId", SqlDbType.Int, 0, ParameterDirection.Input, categoryId);

            SetCommandType(sqlCmd, CommandType.StoredProcedure, "spr_TblProductBrand_GetAllTblProductBrandByPartnerCategoryId");
            GenerateCollectionFromReader reader = new GenerateCollectionFromReader(GenerateTblProductBrandCollectionFromReader);
            CustomCollection<Manufacturer> objCollection = ((CustomCollection<Manufacturer>)ExecuteReaderCmd(sqlCmd, reader));

            return objCollection;
        }
        public static CustomCollection<Manufacturer> GetFeaturedProductBrands(int howMany)
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@HowMany", SqlDbType.Int, 0, ParameterDirection.Input, howMany);

            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_PRODUCTBRAND_GET_TBL_PRODUCT_BRAND_FOR_FEATURED);
            GenerateCollectionFromReader reader = new GenerateCollectionFromReader(GenerateTblProductBrandCollectionFromReader);
            CustomCollection<Manufacturer> objCollection = ((CustomCollection<Manufacturer>)ExecuteReaderCmd(sqlCmd, reader));

            return objCollection;
        }

        public static CustomCollection<Manufacturer> GetActiveProductBrands(int howMany)
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@HowMany", SqlDbType.Int, 0, ParameterDirection.Input, howMany);

            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_PRODUCTBRAND_GET_TBL_PRODUCT_BRAND_ACTIVE);
            GenerateCollectionFromReader reader = new GenerateCollectionFromReader(GenerateTblProductBrandCollectionFromReader);
            CustomCollection<Manufacturer> objCollection = ((CustomCollection<Manufacturer>)ExecuteReaderCmd(sqlCmd, reader));

            return objCollection;
        }

        public static int GetProductBrandCountByName(string brandName)
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();

            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            AddParameterToSqlCmd(sqlCmd, "@BrandName", SqlDbType.NVarChar, 500, ParameterDirection.Input, brandName);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_PRODUCTBRAND_GET_PRODUCT_BRAND_COUNT_BY_NAME);
            ExecuteScalarCmd(sqlCmd);

            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return returnValue;
        }

        public static bool TemporaryDeleteBrands(List<int> deleteIds)
        {
            //Validate Input
            foreach (Int32 productBrandId in deleteIds)
                if (productBrandId <= GetProductBrandIdMinValue)
                    throw (new ArgumentOutOfRangeException("productBrandId"));

            //performing deletion operation //

            string xmlString = FormatXMLForIdArray(deleteIds);

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            AddParameterToSqlCmd(sqlCmd, "@ProductBrandIdList", SqlDbType.Xml, xmlString.ToString().Length, ParameterDirection.Input, xmlString.ToString());
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBLPRODUCTBRAND_TEMPORARY_DELETE_BRANDS);
            ExecuteScalarCmd(sqlCmd);
            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return (returnValue == deleteIds.Count ? true : false);
        }

        public static CustomCollection<Manufacturer> GetNonDeletedBrands()
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();

            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_PRODUCTBRAND_GET_TBL_PRODUCT_BRAND_NONDELETED);
            GenerateCollectionFromReader reader = new GenerateCollectionFromReader(GenerateTblProductBrandCollectionFromReader);
            CustomCollection<Manufacturer> objCollection = ((CustomCollection<Manufacturer>)ExecuteReaderCmd(sqlCmd, reader));

            return objCollection;
        }

        public static Manufacturer GetTblProductBrandByProductBrandName(string brandName)
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@BrandName", SqlDbType.NVarChar, 500, ParameterDirection.Input, brandName);

            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_PRODUCTBRAND_GET_TBL_PRODUCT_BRAND_BY_NAME);
            GenerateCollectionFromReader reader = new GenerateCollectionFromReader(GenerateTblProductBrandCollectionFromReader);
            CustomCollection<Manufacturer> objCollection = ((CustomCollection<Manufacturer>)ExecuteReaderCmd(sqlCmd, reader));

            if (objCollection.Count > 0)
                return objCollection[0];
            else
                return null;
        }

        public static Manufacturer GetTblProductBrandByProductBrandUrl(string brandUrl)
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@BrandName", SqlDbType.NVarChar, 500, ParameterDirection.Input, brandUrl);

            SetCommandType(sqlCmd, CommandType.StoredProcedure, "spr_TblProductBrand_GetProductBrandByUrl");
            GenerateCollectionFromReader reader = new GenerateCollectionFromReader(GenerateTblProductBrandCollectionFromReader);
            CustomCollection<Manufacturer> objCollection = ((CustomCollection<Manufacturer>)ExecuteReaderCmd(sqlCmd, reader));

            if (objCollection.Count > 0)
                return objCollection[0];
            else
                return null;
        }

        #region TblProductBrand Static Methods
        /************************************************************************************
                                    -- CREATE METHOD (STATIC) --
        *************************************************************************************/
        /************************* Architecure note:**********************************
        Note 1:
        This method is specially useful for the case, where we need to use Object Data Source controls.
        For ObjectDataSource/SqlDataSource controls, the insert/update metnod requires paramters methods, rather property based methods.
        However, there is still a way to pass property based objects as method parameter for data source controls, 
        but in that case we could not use Sql type, as view controls or asp parameter control can only contain few of primitive type.
        The main reason to remain the Sql Type in our object architecture is it is faster and contains better way for null value support.
        
        Note 2: 
        Non-primary key: it should be primitive type, as the asp paramter control (included in data source control) supports only primitive types.
        /*****************************************************************************/
        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Insert, true)]
        public static Int32 CreateNewTblProductBrand
        (
            String brandName,
            String brandDescription,
            String brandImageUrl,
            String brandUrl,
            Boolean isActive,
            String brandBannerUrl
        )
        {
            //creating an empty TblProductBrand object
            Manufacturer item = new Manufacturer();
            item.BrandName = brandName;
            item.BrandDescription = brandDescription;
            item.BrandImageUrl = brandImageUrl;
            item.BrandUrl = brandUrl;
            item.IsActive = isActive;
            item.BrandBannerImageUrl = brandBannerUrl;

            return ManufacturerDAO.CreateNewTblProductBrand(item);
        }

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
        public static bool UpdateTblProductBrand
        (
            Int32 productBrandId,
            String brandName,
            String brandDescription,
            String brandImageUrl,
            String brandUrl,
            Boolean isActive,
            String brandBannerUrl
        )
        {
            Manufacturer item = ManufacturerDAO.GetTblProductBrandByProductBrandId(productBrandId);

            item.BrandName = brandName;
            item.BrandDescription = brandDescription;
            item.BrandImageUrl = brandImageUrl;
            item.BrandUrl = brandUrl;
            item.IsActive = isActive;
            item.BrandBannerImageUrl = brandBannerUrl;

            return ManufacturerDAO.UpdateTblProductBrand(item);
        }

        /************************************************************************************
                         -- DELETE METHODS --
        *************************************************************************************/
        /************************* Architecure note:**********************************
        We have used the employeeId parameter as SqlInt32, to bind the delete method with object data source and view control directly.
        ****************************************************************************/
        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
        public static bool DeleteTblProductBrand
        (
            Int32 productBrandId
        )
        {
            //Validate Input
            if (productBrandId <= GetProductBrandIdMinValue)
                throw (new ArgumentOutOfRangeException("productBrandId"));

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            AddParameterToSqlCmd(sqlCmd, "@ProductBrandId", SqlDbType.Int, 0, ParameterDirection.Input, productBrandId);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SPR_TBLPRODUCTBRAND_DELETETBLPRODUCTBRAND);
            ExecuteScalarCmd(sqlCmd);
            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return (returnValue == 0 ? false : true);

        }

        /// <summary>
        /// Deletes a set of employees from the database.
        /// </summary>
        public static bool DeleteTblProductBrandList(System.Collections.Generic.List<Int32> productBrandIdListToDelete)
        {
            //Validate Input
            foreach (Int32 productBrandId in productBrandIdListToDelete)
                if (productBrandId <= GetProductBrandIdMinValue)
                    throw (new ArgumentOutOfRangeException("productBrandId"));

            //performing deletion operation //

            string xmlString = FormatXMLForIdArray(productBrandIdListToDelete);

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            AddParameterToSqlCmd(sqlCmd, "@ProductBrandIdList", SqlDbType.Xml, xmlString.ToString().Length, ParameterDirection.Input, xmlString.ToString());
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SPR_TBLPRODUCTBRAND_DELETETBLPRODUCTBRANDLIST);
            ExecuteScalarCmd(sqlCmd);
            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return (returnValue == productBrandIdListToDelete.Count ? true : false);
        }

        /************************************************************************************
                                 -- GET BY PRIMARY METHODS --
        *************************************************************************************/
        /************************* Architecure note:**********************************
        Retrives an Employee from database, based on it's primary key.
        To view or update an employee, everytime we must have to use this type of 'get' method, 
        since we don't have direct access to the Primary key value for assigning value.
        We have used the employeeId parameter as SqlInt32, to bind the delete method with object data source and view control directly.
        /*****************************************************************************/
        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public static Manufacturer GetTblProductBrandByProductBrandId(Int32 productBrandId)
        {
            if (productBrandId <= GetProductBrandIdMinValue)
                throw (new ArgumentOutOfRangeException("productBrandId"));

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@ProductBrandId", SqlDbType.Int, 0, ParameterDirection.Input, productBrandId);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SPR_TBLPRODUCTBRAND_GETTBLPRODUCTBRANDBYPRODUCTBRANDID);
            GenerateCollectionFromReader reader = new GenerateCollectionFromReader(GenerateTblProductBrandCollectionFromReader);
            CustomCollection<Manufacturer> items = ((CustomCollection<Manufacturer>)ExecuteReaderCmd(sqlCmd, reader));

            if (items.Count > 0)
                return items[0];
            else
                return null;
        }

        /************************************************************************************
                         -- GET BY FOREIGN KEY METHODS --
        *************************************************************************************/

        /************************************************************************************
                 -- GET ALL METHODS --
        *************************************************************************************/
        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public static CustomCollection<Manufacturer> GetAllTblProductBrand()
        {

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SPR_TBLPRODUCTBRAND_GETALLTBLPRODUCTBRAND);
            GenerateCollectionFromReader reader = new GenerateCollectionFromReader(GenerateTblProductBrandCollectionFromReader);
            CustomCollection<Manufacturer> items = ((CustomCollection<Manufacturer>)ExecuteReaderCmd(sqlCmd, reader));

            return items;
        }

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public static CustomCollection<Manufacturer> GetAllTblProductBrandPaged(String orderBy, Int32 startRowIndex, Int32 maximumRows)
        {
            //Validate Input
            if (orderBy == "")
                orderBy = "ProductBrandId";

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@orderby", SqlDbType.VarChar, 50, ParameterDirection.Input, orderBy);
            AddParameterToSqlCmd(sqlCmd, "@startrow", SqlDbType.Int, 0, ParameterDirection.Input, startRowIndex);
            AddParameterToSqlCmd(sqlCmd, "@pagesize", SqlDbType.Int, 0, ParameterDirection.Input, maximumRows);

            SetCommandType(sqlCmd, CommandType.StoredProcedure, SPR_TBLPRODUCTBRAND_GETALLTBLPRODUCTBRANDPAGED);

            GenerateCollectionFromReader reader = new GenerateCollectionFromReader(GenerateTblProductBrandCollectionFromReader);
            CustomCollection<Manufacturer> items = ((CustomCollection<Manufacturer>)ExecuteReaderCmd(sqlCmd, reader));
            return items;
        }

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public static int GetAllTblProductBrandPagedCount(String orderBy, Int32 startRowIndex, Int32 maximumRows)
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();

            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SPR_TBLPRODUCTBRAND_GETALLTBLPRODUCTBRANDPAGEDCOUNT);
            ExecuteScalarCmd(sqlCmd);

            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return returnValue;
        }

        #endregion
        public bool Save(Manufacturer item)
        {
            if (item.ProductBrandId <= GetProductBrandIdMinValue)
            {
                item.ProductBrandId = CreateNewTblProductBrand(item);
                if (item.ProductBrandId > 0)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return (UpdateTblProductBrand(item));
            }

        }

        public static Int32 CreateNewTblProductBrand(Manufacturer item)
        {
            // validate Parameters
            if (item == null)
                throw (new ArgumentNullException("newTblProductBrand"));

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            int length = 0;
            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);

            AddParameterToSqlCmd(sqlCmd, "@BrandName", SqlDbType.NVarChar, 500, ParameterDirection.Input, item.BrandName);
            AddParameterToSqlCmd(sqlCmd, "@BrandDescription", SqlDbType.NVarChar, 4000, ParameterDirection.Input, item.BrandDescription);
            AddParameterToSqlCmd(sqlCmd, "@BrandImageUrl", SqlDbType.NVarChar, 500, ParameterDirection.Input, item.BrandImageUrl);
            AddParameterToSqlCmd(sqlCmd, "@BrandUrl", SqlDbType.NVarChar, 500, ParameterDirection.Input, item.BrandUrl);
            AddParameterToSqlCmd(sqlCmd, "@IsActive", SqlDbType.Bit, 0, ParameterDirection.Input, item.IsActive);
            AddParameterToSqlCmd(sqlCmd, "@IsFeatured", SqlDbType.Bit, 0, ParameterDirection.Input, false);
            AddParameterToSqlCmd(sqlCmd, "@IsDeleted", SqlDbType.Bit, 0, ParameterDirection.Input, false);
            AddParameterToSqlCmd(sqlCmd, "@DateCreated", SqlDbType.DateTime, 0, ParameterDirection.Input, DateTime.Now);
            AddParameterToSqlCmd(sqlCmd, "@BrandCode", SqlDbType.NVarChar, 50, ParameterDirection.Input, string.Empty);
            AddParameterToSqlCmd(sqlCmd, "@BrandBannerUrl", SqlDbType.NVarChar, -1, ParameterDirection.Input, item.BrandBannerImageUrl);

            SetCommandType(sqlCmd, CommandType.StoredProcedure, SPR_TBLPRODUCTBRAND_CREATENEWTBLPRODUCTBRAND);
            ExecuteScalarCmd(sqlCmd);
            return (Int32.Parse(sqlCmd.Parameters["@ReturnValue"].Value.ToString()));

        }

        public static bool UpdateTblProductBrand(Manufacturer item)
        {
            // validate Parameters
            if (item == null)
                throw (new ArgumentNullException("newTblProductBrand"));

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            int length = 0;
            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);

            AddParameterToSqlCmd(sqlCmd, "@ProductBrandId", SqlDbType.Int, 0, ParameterDirection.Input, item.ProductBrandId);
            AddParameterToSqlCmd(sqlCmd, "@BrandName", SqlDbType.NVarChar, 500, ParameterDirection.Input, item.BrandName);
            AddParameterToSqlCmd(sqlCmd, "@BrandDescription", SqlDbType.NVarChar, 4000, ParameterDirection.Input, item.BrandDescription);
            AddParameterToSqlCmd(sqlCmd, "@BrandImageUrl", SqlDbType.NVarChar, 500, ParameterDirection.Input, item.BrandImageUrl);
            AddParameterToSqlCmd(sqlCmd, "@BrandUrl", SqlDbType.NVarChar, 500, ParameterDirection.Input, item.BrandUrl);
            AddParameterToSqlCmd(sqlCmd, "@IsActive", SqlDbType.Bit, 0, ParameterDirection.Input, item.IsActive);
            AddParameterToSqlCmd(sqlCmd, "@IsFeatured", SqlDbType.Bit, 0, ParameterDirection.Input, false);
            AddParameterToSqlCmd(sqlCmd, "@IsDeleted", SqlDbType.Bit, 0, ParameterDirection.Input, false);
            AddParameterToSqlCmd(sqlCmd, "@DateCreated", SqlDbType.DateTime, 0, ParameterDirection.Input, DateTime.Now);
            AddParameterToSqlCmd(sqlCmd, "@BrandCode", SqlDbType.NVarChar, 50, ParameterDirection.Input, string.Empty);
            AddParameterToSqlCmd(sqlCmd, "@BrandBannerUrl", SqlDbType.NVarChar, -1, ParameterDirection.Input, item.BrandBannerImageUrl);

            SetCommandType(sqlCmd, CommandType.StoredProcedure, SPR_TBLPRODUCTBRAND_UPDATETBLPRODUCTBRAND);
            ExecuteScalarCmd(sqlCmd);
            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return (returnValue == 0 ? false : true);
        }

        public static CollectionBase GenerateTblProductBrandCollectionFromReader(IDataReader returnData)
        {
            CustomCollection<Manufacturer> items = new CustomCollection<Manufacturer>();
            while (returnData.Read())
            {
                Manufacturer item = new Manufacturer()
                {
                    ProductBrandId = returnData["ProductBrandId"] == System.DBNull.Value ? GetProductBrandIdMinValue : (Int32)returnData["ProductBrandId"],
                    BrandName = returnData["BrandName"] == System.DBNull.Value ? string.Empty : (String)returnData["BrandName"],
                    BrandDescription = returnData["BrandDescription"] == System.DBNull.Value ? string.Empty : (String)returnData["BrandDescription"],
                    BrandImageUrl = returnData["BrandImageUrl"] == System.DBNull.Value ? string.Empty : (String)returnData["BrandImageUrl"],
                    BrandUrl = returnData["BrandUrl"] == System.DBNull.Value ? string.Empty : (String)returnData["BrandUrl"],
                    IsActive = returnData["IsActive"] == System.DBNull.Value ? false : (Boolean)returnData["IsActive"],
                    BrandBannerImageUrl = returnData["BrandBannerUrl"] == System.DBNull.Value ? string.Empty : (String)returnData["BrandBannerUrl"]
                };
                items.Add(item);
            }

            return (items);
        }

        public static Int32 GetProductBrandIdMinValue
        {
            get
            {
                return 0;
            }
        }

        //create method related contants
        internal const string SPR_TBLPRODUCTBRAND_CREATENEWTBLPRODUCTBRAND = "spr_TblProductBrand_CreateNewTblProductBrand";
        internal const string SPR_TBLPRODUCTBRAND_UPDATETBLPRODUCTBRAND = "spr_TblProductBrand_UpdateTblProductBrand";
        internal const string SPR_TBLPRODUCTBRAND_DELETETBLPRODUCTBRAND = "spr_TblProductBrand_DeleteTblProductBrand";
        internal const string SPR_TBLPRODUCTBRAND_DELETETBLPRODUCTBRANDLIST = "spr_TblProductBrand_DeleteTblProductBrandList";
        internal const string SPR_TBLPRODUCTBRAND_GETTBLPRODUCTBRANDBYPRODUCTBRANDID = "spr_TblProductBrand_GetTblProductBrandByProductBrandId";
        internal const string SPR_TBLPRODUCTBRAND_GETALLTBLPRODUCTBRAND = "spr_TblProductBrand_GetAllTblProductBrand";
        internal const string SPR_TBLPRODUCTBRAND_GETALLTBLPRODUCTBRANDPAGED = "spr_TblProductBrand_GetAllTblProductBrandPaged";
        internal const string SPR_TBLPRODUCTBRAND_GETALLTBLPRODUCTBRANDPAGEDCOUNT = "spr_TblProductBrand_GetAllTblProductBrandPagedCount";

        private const string SP_TBL_PRODUCTBRAND_GET_TBL_PRODUCT_BRAND_BY_NAME = "sp_TblProductBrand_Get_ProductBrand_By_Name";
        private const string SP_TBL_PRODUCTBRAND_GET_TBL_PRODUCT_BRAND_BY_PREFIX = "sp_TblProductBrand_Get_ProductBrand_By_Prefix";
        private const string SP_TBL_PRODUCTBRAND_GET_TBL_PRODUCT_BRAND_BY_CONDITION = "sp_TblProductBrand_Get_ProductBrand_By_Condition";
        private const string SP_TBL_PRODUCTBRAND_GET_TBL_PRODUCT_BRAND_FOR_FEATURED = "sp_TblProductBrand_Get_ProductBrand_For_Featured";
        private const string SP_TBL_PRODUCTBRAND_GET_TBL_PRODUCT_BRAND_ACTIVE = "sp_TblProductBrand_Get_ProductBrand_Active";
        private const string SP_TBL_PRODUCTBRAND_GET_PRODUCT_BRAND_COUNT_BY_NAME = "sp_TblProductBrand_Get_ProductBrand_Count_By_Name";
        private const string SP_TBLPRODUCTBRAND_TEMPORARY_DELETE_BRANDS = "sp_TblProductBrand_Temporary_Delete_Brands";
        private const string SP_TBL_PRODUCTBRAND_GET_TBL_PRODUCT_BRAND_NONDELETED = "sp_TblProductBrand_Get_ProductBrand_NonDeleted";
    }
}
